feat(util-retry): support AbortSignal in DefaultRateLimiter.getSendToken#1887
Open
TrevorBurnham wants to merge 1 commit intosmithy-lang:mainfrom
Open
feat(util-retry): support AbortSignal in DefaultRateLimiter.getSendToken#1887TrevorBurnham wants to merge 1 commit intosmithy-lang:mainfrom
TrevorBurnham wants to merge 1 commit intosmithy-lang:mainfrom
Conversation
When the DefaultRateLimiter is waiting for token bucket capacity, the setTimeout delay could not be cancelled. This is problematic in environments like AWS Lambda where you may need to abort the retry wait as the function timeout approaches. getSendToken now accepts an optional AbortSignal parameter. When provided, the signal is raced against the delay timer: - If the signal is already aborted, the promise rejects immediately with the signal's reason. - If the signal fires during the wait, the timer is cleared and the promise rejects with the signal's reason. - If no signal is provided, behavior is unchanged. The RateLimiter interface in both util-retry and middleware-retry is updated to accept the optional parameter. Fixes smithy-lang#1758
Contributor
|
What is the proposed control mechanism used with a client and a request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Fixes #1758
Description of changes:
When the
DefaultRateLimiteris waiting for token bucket capacity viagetSendToken, the internalsetTimeoutdelay cannot be cancelled. In environments like AWS Lambda, this means you can't abort a retry wait as the function timeout approaches — the Lambda just fails with a "task timed out" error instead of letting you handle it gracefully.getSendTokennow accepts an optionalAbortSignal. When provided, the signal is raced against the delay timer:signal.reason.signal.reason.The
RateLimiterinterface is updated in both@smithy/util-retryand@smithy/middleware-retryto accept the optional parameter.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.